package com.crm.common.helper;

import cn.hutool.core.date.DateTime;
import com.crm.common.util.DateUtil;
import com.crm.common.util.DateUtils;
import java.util.Date;

/**
 * @Description: TODO
 * @Author lixq-f
 * @Date 2021/6/26
 * @Version V1.0
 **/
public class TimePeriod {

    //全部
    private static final int ALL_YEAR = 0;
    //今日
    private static final int THIS_DAY = 1;
    //本周
    private static final int THIS_WEEK = 2;
    //本月
    private static final int THIS_MONTH = 3;
    //上月
    private static final int LAST_MONTH = 4;


    public static Date getStartTime(Integer dateType) {
        if (null == dateType){
            return null;
        }
        switch (dateType) {
            case ALL_YEAR:
                return DateUtils.beginOfYear(DateUtil.getSysDate());
            case THIS_DAY:
                return DateUtil.getDateStart(DateUtil.getSysDate());
            case THIS_WEEK:
                return DateUtils.beginOfWeek(DateUtil.getSysDate());
            case THIS_MONTH:
                return DateUtils.beginOfMonth(DateUtil.getSysDate());
            case LAST_MONTH:
                DateTime dateTime = DateUtils.lastMonth();
                return DateUtils.beginOfMonth(dateTime);
            default:
        }
        return null;
    }

    public static Date getEndTime(Integer dateType) {
        if (null == dateType){
            return null;
        }
        switch (dateType) {
            case ALL_YEAR:
                return DateUtils.endOfYear(DateUtil.getSysDate());
            case THIS_DAY:
                return DateUtil.getDateEnd(DateUtil.getSysDate());
            case THIS_WEEK:
                return DateUtils.endOfWeek(DateUtil.getSysDate());
            case THIS_MONTH:
                return DateUtils.endOfMonth(DateUtil.getSysDate());
            case LAST_MONTH:
                DateTime dateTime = DateUtils.lastMonth();
                return DateUtils.endOfMonth(dateTime);
            default:
        }
        return null;
    }





}
